<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/lib/DanhMuc.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/lib/Sanpham.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/lib/User.php';
$danhmucOb = new DanhMuc();
$danhmucList = $danhmucOb->layDanhSachDanhMuc(DanhMuc::HIEN);
$sanphamOb = new Sanpham();
$user = new User();
$lienhe = $user->layLienHe(1);
if (isset($_POST['username']) && isset($_POST['password'])) {
    if ($user->kiemtradangnhapuser($_POST['username'], $_POST['password'])) {
        
    } else {
        header('Location: index.php');
    }
}
$spDacBietList = $sanphamOb->laySanPhamDacBiet();
?>
<div id="sidebar"><div class="sidebar_top"></div>
    <div class="sidebar_section">
        <?php if ($user->daDangNhap()): ?>
            <marquee><h2>Chào&nbsp;<?php echo $_SESSION['session_id_user']; ?>!</h2><br/></marquee>
            <a href="dangxuat.php">Đăng xuất</a><br/>
        <?php else: ?>
            <h2><strong>Đăng nhập</strong></h2>
            <form action="" method="post" name="DangNhap">
                <label>Tên đăng nhập</label>
                <input type="text"  name="username" id="username" size="10" class="input_field" title="username" />
                <span id="thongbaodangnhap"></span>
                <label>Mật khẩu</label>
                <input type="password" name="password" id="password" class="input_field" title="password" />
                <a href="dangky.php">Đăng ký</a>
                <input type="submit" name="login" value="Đăng nhập" id="submit_btn" title="login" />
            </form>
        <?php endif; ?>
        <div class="cleaner"></div>
    </div>
    <div class="sidebar_section">

        <h3 align="center">Danh mục sản phẩm</h3>
        <ul class="categories_list">
            <li>
                <?php foreach ($danhmucList as $item): ?>
                <li><a href="sanphamtheodanhmuc.php?id=<?php echo $item['id'] ?>"><?php echo $item['tieude'] ?></a></li>
            <?php endforeach; ?>
            </li>
        </ul>
    </div>
    <div class="sidebar_section">
        <p style="text-align: center; ">
            <a href="ymsgr:sendim?<?php echo $lienhe['yahoo'] ?>" style="text-decoration: none;"><img border="0" src="http://opi.yahoo.com/online?u=<?php echo $lienhe['yahoo'] ?>&amp;m=g&amp;t=2" /></a></p>
        <p style="text-align: center;">
            <span style="font-family:georgia,serif;"><em><strong><span style="color: rgb(0, 0, 128);"><?php echo $lienhe['tenchu'] ?></span></strong></em></span><br />
            <span style="color: rgb(255,0,51); font-size: 15px; font-weight: bold">&nbsp;Hotline: <?php echo $lienhe['sodienthoai'] ?></span></p>
    </div>
    <h3 align="center">Đặc biệt<h3>

            <div class="product_box">
                <?php while ($sp = mysql_fetch_assoc($spDacBietList)): ?>
                    <h3><?php echo $sp['ten'] ?></h3>
                    <div class="image_wrapper"> 
                        <a href="chitietsanpham.php?id=<?php echo $sp['id'] ?>" target="_parent"><img class="img" src="<?php echo $sp['hinhanh'] ?>" /></a> 
                    </div>
                    <p class="price" align="center">Giá: <?php echo number_format($sp['gia']) ?> VNĐ</p>
                <?php endwhile; ?>
            </div>
            </div> <!-- end of sidebar -->
